package cn.com.twoke.easyproject;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.sql.SQLException;

@Slf4j
@Component
@RequiredArgsConstructor
public class InitRunner implements ApplicationRunner {

    private final DataSource dataSource;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
            dataSource.getConnection();
        }catch (SQLException e) {
            log.error("数据库配置错误，请检查数据库配置");
        }
//        catch (RedisConnectionFailureException e) {
//            log.error("redis配置错误，请检查redis配置");
//        }
        catch (Exception e) {
            log.error("服务启动失败", e);
        }
    }


}